Skip to main content

Notifications

Copilot Studio - General
Unanswered

Conversation start topic is not triggered when creating a token through v3/directline/conversations API

(0) ShareShare
ReportReport
Posted on by

I am writing a React native web app that connects to a bot in Copilot studio.

 

To render the chat I am using the `ReactWebChat` component with a directLine object, this object has its token set like this:

 

 

 

 const initializeDirectLine = async () => {
 try {
 const storedToken = localStorage.getItem('directLineToken');
 if (storedToken) {
 return createDirectLine({ token: storedToken });
 } else {
 const response = await fetch('https://unitedstates.directline.botframework.com/v3/directline/conversations', {
 method: 'POST',
 headers: {
 Authorization: `Bearer SECRET`
 }
 });

 if (response.ok) {
 const data = await response.json();
 localStorage.setItem('directLineToken', data.token);
 return createDirectLine({ token: data.token });
 } else {
 console.error('Failed to start conversation:', response.statusText);
 return {};
 }
 }
 } catch (error) {
 console.error('Error initializing Direct Line:', error);
 return {};
 }
 };

 

 

 

 

I am able to establish a connection with my bot and the conversations API call is successful, however the Conversation Start topic is not triggered (it is triggered for instance in the Test pane in Copilot Studio and also in the Demo Website, same if I were to just copy the iFrame HTML). 

 

Anything I might be doing wrong with the above code? I also tried just copying a token from the conversations API call from the Demo website and the Conversation Start is triggered but not if I generate the token directly from a fetch call.

Categories:
  • MG-11012106-0 Profile Picture
    MG-11012106-0 2 on at
    Conversation start topic is not triggered when creating a token through v3/directline/conversations API
    Having the same problem.  Has anyone found an answer to this yet?
  • CU14081638-0 Profile Picture
    CU14081638-0 4 on at
    Conversation start topic is not triggered when creating a token through v3/directline/conversations API
    I have same issue. Did you get answer for this
  • JS-19071634-0 Profile Picture
    JS-19071634-0 4 on at
    Conversation start topic is not triggered when creating a token through v3/directline/conversations API
    Has anyone found an answer to this?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,580

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,909

Leaderboard