Skip to main content

Notifications

Power Platform Community / Forums / General / Getting issue with cal...
General
Unanswered

Getting issue with calling API for directlinetoken

Posted on by 6

API : https://powerva.microsoft.com/api/botmanagement/v1/directline/directlinetoken?botId=525a5cab-abac-4294-ba69-888b02&tenantId=b0b120fd-1701-4d59-9e7d-9cd

 

Response : 

{
 "ErrorCode": 4103,
 "ErrorMessage": "ItemWithIdNotFound",
 "DiagnosticsMessage": null,
 "ErrorInfo": null
}

 

  • Israel_Ramakuri Profile Picture
    Israel_Ramakuri 9 on at
    Re: Getting issue with calling API for directlinetoken

    Below is the url for the directline.

     

    https://powerva.microsoft.com/api/botmanagement/v1/directline/directlinetoken?botId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&tenantId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

     

    Israel_Ramakuri_1-1686766066307.png

     

    Pick Tenant ID and Bot ID from PVA Chatbot Settings-->Details-->Advanced Tab

    Tenant ID can be used as it is as shown in your chatbot details page.

    For Bot ID, pick it from the Schema name. Default format will be like below. new_bot_485e1cc7e5d64e76bfa0ea3208d09e91

    To use in the DirectLine it should be as below.(Ignore the new_bot_ and split the rest of the id as per below format)

    485e1cc7-e5d6-4e76-bfa0-ea3208d09e91.

     

    Hope this helps. 

     

     

     

  • Israel_Ramakuri Profile Picture
    Israel_Ramakuri 9 on at
    Re: Getting issue with calling API for directlinetoken

    Thank you. This saved a lot of mental pressure. Dont know why this is made so complex.

     

  • HenryJammes Profile Picture
    HenryJammes on at
    Re: Getting issue with calling API for directlinetoken

     I don't think this part is automatic.
    You need to send a start conversation event from your chat client to the Direct Line API:

    E.g. a POST to https://directline.botframework.com/v3/directline/conversations/9jkHsnW3lXLJVtqNSzKiMc-us/activities (with your own conversation ID and bearer token) with this body: 

     

     

    {
     "type": "event",
     "name": "startConversation"
    }

     

     

    Then this should trigger the Conversation Start topic.

     

    This is detailed here: Automatically start a chatbot conversation - Power Virtual Agents | Microsoft Learn

  • Vicky001 Profile Picture
    Vicky001 6 on at
    Re: Getting issue with calling API for directlinetoken

    Once I load my chabot using token endpoint URL, the start conversation topic is not working. 

    Vicky001_0-1683258999944.png

    And this one my bot topic. 

    Vicky001_1-1683259092899.png

     

     

  • GnanavelBala Profile Picture
    GnanavelBala 10 on at
    Re: Getting issue with calling API for directlinetoken

    Hi Friends, I needs to have query string parameters to assign values to some bot variables. Is it possible?. If anybody have idea, please help me and guide me. Thanks.

  • GnanavelBala Profile Picture
    GnanavelBala 10 on at
    Re: Getting issue with calling API for directlinetoken

    Yes. I used token endpoint and able to connect. Now I am trying to pass query parameter to bot variable. Is any one tried this?

  • HenryJammes Profile Picture
    HenryJammes on at
    Re: Getting issue with calling API for directlinetoken

    Quick question, why don't you use the token endpoint URL available in PVA to generate the token?

    I.e. this one:

    HenryJammes_0-1683190830404.png

     

  • nikviz Profile Picture
    nikviz 182 on at
    Re: Getting issue with calling API for directlinetoken

    Hi @GnanavelBala 

     


    nikviz_1-1683189564852.png

     

    For me the Bot id is the one highlighted in green.

    nikviz_0-1683190312178.png

     

    And in the code you need to type the bot id in this below format.

    xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
     
    If I dont use this format, i get the same error as you.
  • GnanavelBala Profile Picture
    GnanavelBala 10 on at
    Re: Getting issue with calling API for directlinetoken

    Hi, needs to have query string parameters to assign values to some bot variables. Is it possible?. If anybody have idea, please help me and guide me. Thanks.

  • GnanavelBala Profile Picture
    GnanavelBala 10 on at
    Re: Getting issue with calling API for directlinetoken

    Hi Sir, I tried pass right TenantId & BotId. But I am facing same issue.

     

    const styleOptions = {
    // Add styleOptions to customize web chat canvas
    hideUploadButton: false
    };

    // Add your BOT ID below
    var BOT_ID = "MyBOTID";
    var Tenant_ID = "MyTenantID "

    var theURL = "https://powerva.microsoft.com/api/botmanagement/v1/directline/directlinetoken?botId=" + BOT_ID + "&tenantId=" + Tenant_ID;


    fetch(theURL)
    .then(response => response.json())
    .then(conversationInfo => {
    window.WebChat.renderWebChat(
    {
    directLine: window.WebChat.createDirectLine({
    token: conversationInfo.token,
    }),
    styleOptions
    },
    document.getElementById('webchat')
    );
    })
    .catch(err => console.error("An error occurred: " + err));

     

    Error:

    {
     "ErrorCode": 4103,
     "ErrorMessage": "ItemWithIdNotFound",
     "DiagnosticsMessage": null,
     "ErrorInfo": null
    }

Helpful resources

Quick Links

Exciting News for Copilot Studio Communi…

Get ready to experience a whole new level of engagement with the Copilot Studio…

Celebrating the May Super User of the…

LaurensM is an exceptional contributor to the Power Platform Community…

Check out the Copilot Studio Cookbook…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
renatoromao Profile Picture

renatoromao 6,459

#2
Pstork1 Profile Picture

Pstork1 1,990

#3
Expiscornovus Profile Picture

Expiscornovus 1,700

Leaderboard