integrate Dialogflow v2 with angular 11

Solution for integrate Dialogflow v2 with angular 11
is Given Below:

i’m using dialogflow in application website but now stopped

 readonly toKen = environment.dialogFlow.chatbotAngular;
  readonly client = new ApiAiClient({accessToken : this.toKen});

  conversation = new BehaviorSubject<Message[]>([])
  

  constructor() 
  { 
    const botMessage = new Message('Bienvenue dans votre univers du chatbot,' +
    ' puis-je vous aider ?', 'bot','./assets/media/Awb/chatbot.gif','botcolor');
    this.update(botMessage);
  }


  playAudio()
  {
    let sound = new Audio();
    sound.src="https://stackoverflow.com/questions/68609849/./assets/media/to-the-point-568.ogg";
    sound.load();
    sound.play();
  }

  update(msg : Message)
  {
    this.conversation.next([msg])
  }



  converse(msg : string)
  {

    const userMessage = new Message(msg,'user','./assets/media/users/icon-5359553_1280.png','usercolor');
    this.update(userMessage);

    return this.client.textRequest(msg).then(res =>{

      setTimeout(()=>{
        const speech = res.result.fulfillment.speech;
        const botMessage = new Message(speech, 'bot','./assets/media/Awb/chatbot.gif','botcolor');
        this.update(botMessage);
        this.playAudio();
      }, 5000);

    })
  }

ERROR Error: Uncaught (in promise): ApiAiRequestError: The Dialogflow V1 API is shutting down and can no longer be queried. More details at https://cloud.google.com/dialogflow/docs/release-notes#June_15_2021. Code: 400

As mentioned in the error message, you’ve encountered this issue due to the shutdown of Dialogflow V1 API. With that, you need to migrate your agent to Dialogflow ES or Dialogflow CX to continue working with Dialogflow.

It seems that you want to migrate to Dialogflow ES which uses the V2 API. Kindly note that the request body from Dialogflow V1 API is different from Dialogflow V2 API.

For example, you may check this request body for V2 REST API’s detectIntent method that is equivalent to V1 API’s /query method.

You may also check the available client libraries for Dialogflow V2 API, and see their respective reference documentations and related resources for installation and guidance.

For webhook, you may see the following documentation for the proper format of request and response.

For Angular applications, you may check this discussion and article on how to implement and use it with Dialogflow V2 API.

Moreover, note that the Client Access Token and Developer Access Token that were used as part of the V1 API authentication process are no longer used or available for use in V2 API.

Instead, interactions with the Dialogflow V2 API depend on the use of service accounts. You may visit the following links for further guidance on setting up your service accounts to migrate any services that may be interacting with Dialogflow’s API to V2’s authentication method: