0

I have created a Vertex AI chat agent and embedded it into the NextJS app using the conversation messenger. Below is the code snippet.

<df-messenger
  location="xxxxxxx"
  project-id="xxxxxxxxxxxx"
  agent-id="xxxxxxxxxxxx"
  language-code="en"
  max-query-length="-1"
>
  <df-messenger-chat-bubble chat-title="xxxxxxxxx"></df-messenger-chat-bubble>

</df-messenger>

My NextJS app has login flow in place, and now I want to send the authToken from my chat agent (FE) to vertex ai playbook and which I am unable to do so.

Things I had have tried

1. Setting session-params

const sessionParams = {
      name: 'john doe',
      authToken: '111111111111111',
      userId: 'user_12345',
    };
    
dfMessenger.setAttribute('session-params', JSON.stringify(sessionParams));

However, I am unable to read this value on the vertex ai playbook instructions .I tried using $session.params.name , $session.params.authToken and they are blank

2. I also tried updating the payload of the network request that gets sent from FE to BE (vertex ai agent in this case). Here is the code snippet

 dfMessenger.addEventListener('df-request-sent', function(event) {
      event.detail.data.requestBody = {
        ...event.detail.data.requestBody,
        custom: {
          authToken: 'xxxxxxxxxxxxxxx',
        }
       
      };
    });

On the network call, I could see my custom payload gets added to the request body. However, I am unable to read the request body on the cloud.

On the playbook, I am routing the first interaction to TOOLs where I am invoking a cloud function to read the request, but it's failing to get the custom fields added on the request body.

@functions_framework.http
def process_requset_body_details(request):
request_json = request.get_json()

request_json is also blank for me

Am I missing something here or is there an alternative approach to do this ?

3
  • Please enhance the style of the question to make it more readable and get more interaction. Commented Sep 21 at 11:06
  • Updated the question with more details Commented Sep 21 at 21:14
  • When you say that you're "unable" to do something, your question should also show the code you tried and explain how it doesn't work the way you expect. Just saying "unable" doesn't tell us what the problem is or what you might be doing wrong. Please edit the question to show code that we can copy and run for ourselves to observe the same problem. Commented Sep 22 at 21:51

1 Answer 1

0

This is resolved using queryParams on the frontend side.

I was able to set the queryParams like authToken and userEmail inisde the NextJs App
e.g:

const queryParameters = {
      parameters: {
        authToken: { stringValue: authToken },
        userEmail: { stringValue: userEmail },
      },
    };

dfMessenger.setQueryParameters(queryParameters);

and read them at the agent level inside vertex ai playbook instructions as session params.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.