(projectId, sessionId, queries, languageCode)
| 74 | } |
| 75 | |
| 76 | async function executeQueries(projectId, sessionId, queries, languageCode) { |
| 77 | // Keeping the context across queries let's us simulate an ongoing conversation with the bot |
| 78 | let context; |
| 79 | let intentResponse; |
| 80 | for (const query of queries) { |
| 81 | try { |
| 82 | console.log(`Sending Query: ${query}`); |
| 83 | intentResponse = await detectIntent( |
| 84 | projectId, |
| 85 | sessionId, |
| 86 | query, |
| 87 | context, |
| 88 | languageCode |
| 89 | ); |
| 90 | console.log('Detected intent'); |
| 91 | console.log( |
| 92 | `Fulfillment Text: ${intentResponse.queryResult.fulfillmentText}` |
| 93 | ); |
| 94 | // Use the context from this response for next queries |
| 95 | context = intentResponse.queryResult.outputContexts; |
| 96 | } catch (error) { |
| 97 | console.log(error); |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | executeQueries(projectId, sessionId, queries, languageCode); |
| 102 | // [END dialogflow_detect_intent_text] |
| 103 | } |
no test coverage detected