Victor Muñoz
Victor Muñoz

Reputation: 31

DirectLine Speech: No Welcome Message or Bot Activities Rendered

Description

I'm having an issue when using the DirectLine Speech adapter in my Web Chat integration. I adapted a template that previously worked with the standard DirectLine (text) channel and configured the WebSocket connection on my App Service. While speech-to-text functionality appears to work, the bot integration doesn't seem to be functioning as expected. Specifically:

Code to Reproduce

<script>
    (async function () {
      async function fetchCredentials() {
        const res = await fetch("https://northeurope.api.cognitive.microsoft.com/sts/v1.0/issuetoken", {
          method: "POST",
          headers: {
            "Content-Type": "application/x-www-form-urlencoded",
            "Content-Length": "0",
            "Ocp-Apim-Subscription-Key": "SECRET"
          }
        });
        if (!res.ok) {
          throw new Error("Error al obtener el token de autorización.");
        }
        console.log("Token obtenido correctamente.");
        return { authorizationToken: await res.text(), region: "northeurope" };
      }
      const adapters = await window.WebChat.createDirectLineSpeechAdapters({
        fetchCredentials
      });
      const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
        if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
          console.log("Conexión establecida con Direct Line Speech, enviando evento 'webchat/join'");
          dispatch({
            type: 'WEB_CHAT/SEND_EVENT',
            payload: {
              name: 'webchat/join',
              value: {
                language: "es-ES",
                mail: "[email protected]",
                client: "Cliente123",
                centro: "CentroX",
                ambito: "app",
                traces: "logs"
              }
            }
          });
        }
        return next(action);
      });

      window.WebChat.renderWebChat({
        ...adapters,
        store,
        webSpeechPonyfillFactory: window.WebChat.createBrowserWebSpeechPonyfillFactory()
      }, document.getElementById('webchat'));
      document.querySelector("#webchat > *").focus();
    })().catch(err => console.error("Error al inicializar Web Chat:", err));
  </script>

Expected Behavior

Actual Behavior

Additional Context

Upvotes: 0

Views: 15

Answers (0)

Related Questions